package com.wbdgj.ui.tatter;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.wbdgj.R;

public class TatterSuccessCjActivity extends Dialog {
	private Context context;
	private String titleTxt;
	private String contentTxt;
	private int type;
	private ClickListenerInterface clickListenerInterface;

	public interface ClickListenerInterface {

		public void doConfirm();

		public void doCancel();
	}

	public TatterSuccessCjActivity(Context context, String contentTxt) {
		super(context, R.style.transparentFrameWindowStyle);
		this.context = context;
		this.contentTxt = contentTxt;
	}



	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		init();
	}

	public void init() {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.ui_tatter_success, null);
		setContentView(view);

		ImageView tv_title = (ImageView) view.findViewById(R.id.close);
		ImageView btn_ok = (ImageView) view.findViewById(R.id.know);
		tv_title.setOnClickListener(new clickListener());
		btn_ok.setOnClickListener(new clickListener());

		Window dialogWindow = getWindow();
		WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
		lp.width = (int) (d.widthPixels * 0.8); // 宽度设置为屏幕的0.6
		dialogWindow.setAttributes(lp);
	}

	public void setClicklistener(ClickListenerInterface clickListenerInterface) {
		this.clickListenerInterface = clickListenerInterface;
	}

	private class clickListener implements View.OnClickListener {
		@Override
		public void onClick(View v) {
			int id = v.getId();
			switch (id) {
			case R.id.close:
				clickListenerInterface.doConfirm();
				break;
				case R.id.know:
					clickListenerInterface.doConfirm();
					break;
			}
		}

	};
}
